package com.sikaryofficial.backend.service.points;

import com.sikaryofficial.backend.constant.RedisCacheKey;
import com.sikaryofficial.backend.service.IPointsDetailStrategy;
import com.sikaryofficial.common.core.constant.PointRuleConstant;
import org.springframework.stereotype.Service;

/**
 * @author : qinjinyuan
 * @desc : 积分抽奖服务
 * @date : 2023/10/31 19:03
 */
@Service(value = PointRuleConstant.OWNER_INFO_MODIFY + IPointsDetailStrategy.SUFFIX)
public class OwnerInfoModifyService extends AbstractPointService {
    /**
     * 增加积分后校验
     *
     * @param userId
     * @return
     */
    @Override
    public boolean updatePoints(Long sourceId, Long userId) {
        // 自助评价，当积分大于上限，则不继续增加积分
        boolean isOver = checkPointsOver(userId, PointRuleConstant.OWNER_INFO_MODIFY, RedisCacheKey.OWNER_INFO_MODIFY_POINTS_NUM);
        if (!isOver) {
            // 没有超，则可以继续更新积分
            this.increasePoints(sourceId, userId, PointRuleConstant.OWNER_INFO_MODIFY, "");
            // 增加后，进行统计缓存设置
            this.afterIncreaseNoTime(userId, RedisCacheKey.OWNER_INFO_MODIFY_POINTS_NUM);
            return true;
        }
        return false;
    }
}
